package sb.simple.handle_interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    //符合这个路径规则的接口会经过拦截器
    private String[] includePaths = {
            "/swaggerA/**"
    };
    //符合这个路径规则的接口不会经过拦截器
    private String[] excludePaths = {
            "/swaggerB/**"
    };

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new RequestInterceptor())
                .addPathPatterns(includePaths)
                .excludePathPatterns(excludePaths);
    }
}
